package org.mybatis3.demo1;

import org.apache.ibatis.session.SqlSession;
import org.mybatis3.demo1.dao.UserMapper;
import org.mybatis3.demo1.pojo.User;
import org.mybatis3.util.MyBatisUtil;

import java.util.List;

public class Test8 {
    public static void main(String[] args) {
        SqlSession sqlSession = MyBatisUtil.getSqlSession();

        List<User> userList = sqlSession.getMapper(UserMapper.class).getuserAndRole();
        for (int i = 0; i < userList.size(); i++) {

            System.out.println("用户名：" + userList.get(i).getUserCode() + "；角色名：" + userList.get(i).getRole().getRoleName() + "；地址：" + userList.get(i).getAddress()+";reloCode:"+userList.get(i).getRole().getRoleCode());

        }
        MyBatisUtil.closeSqlSession();
    }
}
